package com.zood.controller;

import com.zood.controller.utils.R;
import com.zood.dao.TemplateDao;
import com.zood.domain.stone;
import com.zood.domain.template;
import com.zood.service.templateService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.io.IOException;

@RestController
@RequestMapping("/template")
public class templateController {
    @Autowired
    private templateService templates;


    @PostMapping
    public R save(@RequestBody template stone) throws IOException {
        boolean flag = templates.save(stone);
        return new R(flag, flag ? "添加成功^_^" : "添加失败-_-!");
    }

    @PutMapping
    public R update(@RequestBody template stone) throws IOException {
        boolean flag = templates.modify(stone);
        return new R(flag, flag ? "修改成功^_^" : "修改失败-_-!");
    }

    @DeleteMapping("{id}")
    public R delete(@PathVariable Integer id){
        return new R(templates.delete(id));
    }
}
